home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE13 / IDAPI / BDEINFO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-17  |  3.0 KB  |  120 lines

  1. unit Bdeinfo;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, DbiErrs, DbiProcs, DbiTypes;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Panel1: TPanel;
  12.     GroupBox1: TGroupBox;
  13.     GroupBox2: TGroupBox;
  14.     chkShare: TCheckBox;
  15.     edNetType: TEdit;
  16.     edNetUser: TEdit;
  17.     edINIFile: TEdit;
  18.     edLDriver: TEdit;
  19.     lbBufsize: TLabel;
  20.     lbHeap: TLabel;
  21.     lbDrivers: TLabel;
  22.     lbClients: TLabel;
  23.     lbSessions: TLabel;
  24.     lbDatabase: TLabel;
  25.     lbCursors: TLabel;
  26.     Label8: TLabel;
  27.     Label9: TLabel;
  28.     Label10: TLabel;
  29.     Label11: TLabel;
  30.     GroupBox3: TGroupBox;
  31.     lbEngVer: TLabel;
  32.     lbDate: TLabel;
  33.     lbTime: TLabel;
  34.     Button1: TButton;
  35.     chkInit: TCheckBox;
  36.     procedure FormCreate(Sender: TObject);
  37.     procedure Button1Click(Sender: TObject);
  38.   private
  39.     { Private declarations }
  40.   public
  41.     { Public declarations }
  42.     procedure GetIDAPIInfo(DoInit: Boolean);
  43.   end;
  44.  
  45. var
  46.   Form1: TForm1;
  47.  
  48. procedure Check(Code: DBIRESULT);
  49.  
  50. implementation
  51.  
  52. {$R *.DFM}
  53.  
  54. procedure Check(Code: DBIRESULT);
  55. var szError: array[0..DBIMAXMSGLEN] of char;
  56. begin
  57.   if Code <> DBIERR_NONE then
  58.   begin
  59.      DbiGetErrorString(Code, szError);
  60.      raise Exception.Create(StrPas(szError));
  61.   end;
  62. end;
  63.  
  64. procedure TForm1.GetIDAPIInfo(DoInit: Boolean);
  65. var SysVer: SYSVersion;
  66.     SysCfg: SYSConfig;
  67.     SysInf: SYSInfo;
  68.     D, M, Hr, Min, Sec: Word;
  69.     Y: Integer;
  70.     thedb : hDBIDb;
  71. begin
  72.   if DoInit then Check(DbiInit(nil));
  73.  
  74.   Check(DbiGetSysVersion(SysVer));
  75.   Check(DbiGetSysConfig(SysCfg));
  76.   Check(DbiGetSysInfo(SysInf));
  77.  
  78.   with SysInf do
  79.   begin
  80.     lbBufSize.Caption  := format('Buffer size:    %8d K', [iBufferSpace]);
  81.     lbHeap.Caption     := format('Heap size:      %8d K', [iHeapSpace]);
  82.     lbDrivers.Caption  := format('Loaded drivers: %6d',   [iDrivers]);
  83.     lbClients.Caption  := format('Active clients: %8d',   [iClients]);
  84.     lbSessions.Caption := format('Sessions:       %9d',   [iSessions]);
  85.     lbDatabase.Caption := format('Open databases: %3d',   [iDatabases]);
  86.     lbCursors.Caption  := format('Cursors:        %10d',  [iCursors]);
  87.   end;
  88.  
  89.   with SysCfg do
  90.   begin
  91.     chkShare.Checked := Boolean(bLocalShare);
  92.     edNetType.Text   := StrPas(szNetType);
  93.     edNetUser.Text   := StrPas(szUserName);
  94.     edINIFile.Text   := StrPas(szIniFile);
  95.     edLDriver.Text   := StrPas(szLangDriver);
  96.   end;
  97.  
  98.   Check(DbiDateDecode(SysVer.dateVer,M,D,Y));
  99.   Check(DbiTimeDecode(SysVer.timeVer,Hr, Min, Sec));
  100.   Sec := Sec div 1000;
  101.  
  102.   lbEngVer.Caption := format('Engine version: %f', [SysVer.iVersion/100]);
  103.   lbDate.Caption   := format('Date: %.2d/%.2d/%d', [D,M,Y]);
  104.   lbTime.Caption   := format('Time: %.2d:%.2d:%.2d', [Hr, Min, Sec]);
  105.  
  106.   if DoInit then Check(DbiExit);
  107. end;
  108.  
  109. procedure TForm1.FormCreate(Sender: TObject);
  110. begin
  111.   GetIDAPIInfo(False);
  112. end;
  113.  
  114. procedure TForm1.Button1Click(Sender: TObject);
  115. begin
  116.   GetIDAPIInfo(chkInit.Checked);
  117. end;
  118.  
  119. end.
  120.